<template>
  <div class="homeContainer">
    <div class="homeTab">
      <div
        class="homeTabItem"
        :class="{ tabActive: route.name === 'homeRecommend' }"
        @click="switchTab('recommend')"
      >
        个性推荐
      </div>
      <div
        class="homeTabItem"
        :class="{ tabActive: route.name === 'homePlayList' }"
        @click="switchTab('songList')"
      >
        歌单
      </div>
    </div>
    <div class="homeContainerBottom">
      <router-view />
      <!-- <HomeRecommend
        v-if="currentTab === 'recommend'"
        @click="currentTab = 'recommend'"
      /> -->
    </div>
  </div>
</template>

<script setup lang="ts">
// import HomeRecommend from "./components/homeRecommend/homeRecommend.vue";
import { ref } from "vue";
import { useRouter, useRoute } from "vue-router";

const router = useRouter();
const route = useRoute();

const switchTab = (name: string) => {
  // currentTab.value = name;
  if (name === "recommend") {
    router.push({ name: "homeRecommend" });
  } else if (name === "songList") {
    router.push({ name: "homePlayList" });
  }
};

// const currentTab = ref<string>("recommend");
</script>

<style scoped lang="less">
.homeContainer {
  width: 100%;
  height: 100%;
  padding: 10px;
  padding-top: 0;
  overflow-y: auto;
  .homeTab {
    height: 60px;
    display: flex;
    position: sticky;
    top: 0;
    background: #fff;
    width: 100%;
    z-index: 10;
    .homeTabItem {
      padding: 0 8px;
      height: 60px;
      line-height: 60px;
      position: relative;
      cursor: pointer;
      &.tabActive {
        font-weight: bold;
        color: rgb(55, 55, 55);
        &:after {
          content: "";
          display: block;
          position: absolute;
          left: 10%;
          width: 80%;
          bottom: 0px;
          height: 4px;
          background-color: rgb(250, 122, 167);
        }
      }
    }
  }
  .homeContainerBottom {
    margin: 0 auto;
    max-width: 1100px;
  }
}
</style>
